What if we wanted to call 1 shell scripts or execute 1 Bash shell commands when we were writing 1 C programs?
In fact, the header file contains 1 function system () that calls the shell command or script, and it is convenient to simply pass the
start a new process (systemfunction)The system () function can start a new process.int system (const char *string)The effect of this function is equivalent to executing the SH–C string.In general, using the system function is far from the ideal way
Original: http://blog.csdn.NET/nvd11/article/details/8856278What if we wanted to invoke 1 shell scripts or execute 1 Bash shell commands when we were writing 1 C programs?In fact, in this header contains 1 functions called the shell command or
Summary: three methods of executing shell scripts, fork, source and exec, are summarized.
Prerequisites
1. any program we run is a child process generated by the parent process. After the child process is completed, it is returned to the parent
The following system calls are required for process creation under the Unix/linux system: fork/execFork () copies a process into two processes: parent (old PID), child (new PID)EXEC () uses a new program to rewrite the current process: PID has not
When a thread calls a function fork, the entire process address space is copied to the child process, Copy-on-write is mentioned in section 8.3. A child process is a process that is completely different from the parent process, but if neither the
Understanding of fork () functions, and understanding of fork FunctionsAuthor:Wang Shanshan, a lecturer at Huaqing vision embedded College.
For those who are new to Unix/Linux operating systems and Write multi-process programs in Linux, fork is one
Turn from: http://blog.csdn.net/anxuegang/article/details/6658472
Preface:The EXCE call does not create a new process, so the process ID does not change, and exec simply replaces the body, data, heap, and stack segments of the current process with
Fork is not allowed in multi-threaded programs
Code of design for C ++ on UNIX 3
Criterion 3: fork is not allowed in multithreaded programs
When fork is used in a multi-threaded program, it may cause various problems. A typical example is that the
(1) Fork system call DescriptionThe fork system call is used to create a new process from an existing process called a child process, and the original process is called the parent process. The fork is called once, returned two times, and the two
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.